/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bgate.core;

import javax.microedition.lcdui.Graphics;

/**
 *
 * @author thinhnv
 */
public abstract class View {

    public Screen screen;
    public int width;
    public int height;
    public int delay;
    public int state, beforeState;
    public int typeScreen;
    public boolean show;

    public View(Screen screen) {
        this.screen = screen;
        this.width = screen.getWidth();
        this.height = screen.getHeight();
        this.delay = screen.delay;
        this.typeScreen = this.screen.type;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public void setState(int newState) {
        beforeState = state;
        state = newState;
    }

    public void show(boolean show) {
        this.show = show;
    }

    public boolean isShow() {
        return this.show;
    }

    public abstract void init();

    public abstract void update();

    public abstract void present(Graphics g);

    public abstract void pause();

    public abstract void resume();

    public abstract void dispose();

    // <editor-fold defaultstate="collapsed" desc="KeyPressed">
    public abstract void upKeyPressed();

    public abstract void downKeyPressed();

    public abstract void rightKeyPressed();

    public abstract void leftKeyPressed();

    public abstract void fireKeyPressed();

    public abstract void softKeyLeftPressed();

    public abstract void softKeyRightPressed();

    public abstract void numberKeyPressed(int keyCode);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="KeyReleased">
    public abstract void upKeyRealeased();

    public abstract void downKeyRealeased();

    public abstract void rightKeyRealeased();

    public abstract void leftKeyRealeased();// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="KeyRepeated">
    public abstract void upKeytRepeated();

    public abstract void downKeyRepeated();

    public abstract void rightKeyRepeated();

    public abstract void leftKeyRepeated();// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="TouchHandler">
    public abstract void pointerPressed(int x, int y);

    public abstract void pointerReleased(int x, int y);

    public abstract void pointerDragged(int x, int y);// </editor-fold>

    public boolean inBounds(int pointerX, int pointerY, int boxX, int boxY, int width,
            int height) {
        if (pointerX > boxX && pointerX < boxX + width - 1 && pointerY > boxY
                && pointerY < boxY + height - 1) {
            return true;
        } else {
            return false;
        }
    }
}
